package com.example.springboot.config.anotation.conditionOn.myCondition;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * 自定义condition注解
 *
 * @Author:ChenZhangKun
 * @Date: 2021/5/6 21:13
 */
public class MyCondition implements Condition, ApplicationContextAware {
    private ApplicationContext applicationContext;

    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
        // 有没有
        System.out.println("自定义逻辑过滤是否生效");
        return false;
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
